package com.ruicar.afs.cloud.risk.tortoise.processor.impl;

import com.ruicar.afs.cloud.common.core.util.SpringContextHolder;
import com.ruicar.afs.cloud.risk.api.enums.tortoise.GwtTortoiseScene;
import com.ruicar.afs.cloud.risk.tortoise.dto.notice.GwtTortoiseReq;
import com.ruicar.afs.cloud.risk.tortoise.dto.response.GwtTortoiseResponse;
import com.ruicar.afs.cloud.risk.tortoise.enums.GwtTortoiseNoticeClientUri;
import com.ruicar.afs.cloud.risk.tortoise.processor.GwtTortoiseQueryAndNoticeProcessor;
import com.ruicar.afs.cloud.risk.tortoise.service.AfsCreditTortoiseRecordService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.Set;

/**
 * @Description
 * @Author Peng Jinbo
 * @Date 2020/07/31 20:22
 */
@Component
@AllArgsConstructor
public class GwtTortoiseHandDecisionProcessorImpl implements GwtTortoiseQueryAndNoticeProcessor {

    /**
     * Afs credit tortoise record service
     */
    private AfsCreditTortoiseRecordService afsCreditTortoiseRecordService;

    /**
     * Author Peng Jinbo
     * Belong scene set
     *
     * @return the set
     */
    @Override
    public Set<GwtTortoiseScene> belongScene() {
        return new HashSet(){{add(GwtTortoiseScene.HAND_DECISION_INVOKE);}};
    }

    /**
     * Author Peng Jinbo
     * Query gwt tortoise response
     *
     * @param notice notice
     * @return the gwt tortoise response
     */
    @Override
    public GwtTortoiseResponse query(GwtTortoiseReq notice) {
        return SpringContextHolder.getBean(GwtTortoiseApplyProcessorImpl.class).query(notice);
    }

    /**
     * Author Peng Jinbo
     * Notice gwt tortoise response
     *
     * @param notice notice
     * @return the gwt tortoise response
     */
    @Override
    public GwtTortoiseResponse notice(GwtTortoiseReq notice) {
        afsCreditTortoiseRecordService.noticeToClient(notice, GwtTortoiseNoticeClientUri.NOTICE_CLIENT_URI_DECISION_HAND);
        return GwtTortoiseResponse.success();
    }
}
